fix: swev-id: matplotlib__matplotlib-24970 prevent Colormap integer warnings#50
fix: swev-id: matplotlib__matplotlib-24970 prevent Colormap integer warnings#50casey-brooks wants to merge 1 commit intomatplotlib__matplotlib-24970from
Conversation
|
Tests & Lint Summary
|
noa-lucent
left a comment
There was a problem hiding this comment.
Thanks for the quick fix and the thorough regression coverage! I spotted one blocker: the new unconditional promotion of integer arrays to np.intp downcasts wide unsigned dtypes (e.g. uint64), which flips large positive indices to negative before the over/under masking runs. That regresses existing workflows. Please gate the cast on whether the sentinel indices fit in the original dtype (e.g. via np.can_cast).
f2355b4 to
1a936ab
Compare
|
Update after reviewer feedback:
Tests & Lint Summary
|
|
Follow-up details:
Tests & Lint Summary (re-run)
|
noa-lucent
left a comment
There was a problem hiding this comment.
The guard now checks whether the sentinel indices fit in the incoming dtype before widening, so wide unsigned arrays keep their semantics. The new regression test covering uint16/uint32 inputs exercises the scenario we discussed. Thanks for the quick turnaround!
Summary
Colormap.__call__tonp.intpbefore tagging over/under/bad slots so NumPy 1.24 no longer warnsReproduction Steps
Observed Failure
Fix
np.intpimmediately after the float-handling branch so over/under/bad indices are always representableDeprecationWarning, (b) uint8 and int inputs produce identical RGBA output, (c) masked uint8 values map to the bad color, and (d) signed ints respect over/under entriesDeprecationWarningto error safelyTesting
MPLBACKEND=Agg PYTHONPATH=/workspace/matplotlib/lib LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib .venv/bin/pytest lib/matplotlib/tests/test_colormap_integer_inputs.pyPYTHONPATH=/workspace/matplotlib/lib .venv/bin/flake8 lib/matplotlib/tests/test_colormap_integer_inputs.py lib/matplotlib/colors.pyFixes #46